import React from 'react';
import {
    View,
    Button, Text,
} from 'react-native';

export default class HomeScreen extends React.Component {

    constructor(props){
        super(props);

        this.state={
            title:'这是第1页',
        }
    }

    render() {
        const { navigate } = this.props.navigation; // 可以直接将本页变量，属性什么的传给子项
        return (
            <View>
                <Text>{this.state.title}</Text>

                <Button
                    onPress={() => navigate('Chat',{
                        user: 'xjs',            // 跳转的时候携带一个参数去下个页面
                        callback: (data) => {
                            this.setState({
                                title : data,
                            });
                        }
                    })}
                    title = "带值(xjs)跳转下一页" />
            </View>
        );
    }
}
